import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/a_elder/models/elder_entity.dart';
import 'package:ls_work/res/gaps.dart';
import 'package:ls_work/res/resources.dart';
import 'package:ls_work/viewmodel/activity/activity_sign_view_model.dart';

class ActivitySignPage extends BaseStatefulMvvmWidget {
  final ElderInfo? info;

  ActivitySignPage({this.info});

  @override
  State<StatefulWidget> createState() => _ActivitySignState();
}

class _ActivitySignState
    extends BaseMvvmState<ActivitySignViewModel, ActivitySignPage> {
  @override
  Widget buildLoadingContentView() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        IconTitleTextWidget(
          "长者姓名",
          hintText: "请选择",
          text: viewModel.older?.name??"",
        ).onTap(() {
          if(widget.info==null){
            viewModel.selectOlder();
          }
        }),
        Gaps.line,
        IconTitleTextWidget(
          "参与时间",
          hintText: "请选择",
          text: viewModel.selectDate,
        ).onTap(() {
          viewModel.selectTime();
        }),
        Gaps.midLine,
        CommonText("参与活动").addToContainer(
            margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16)),
        CommonInput(
          hintText: '输入参与的活动',
          border: InputBorder.none,
          padding: EdgeInsets.zero,
          maxLines: 6,
          onChanged: (str){
            viewModel.activityStr = str;
          },
          keyboardType: CommonInputType.multiline,
        ).addToContainer(
            padding: EdgeInsets.all(10),
            decoration: BoxDecoration(
                color: Color(0xffebedf0),
                borderRadius: BorderRadius.circular(8)),
            margin: EdgeInsets.symmetric(horizontal: 16)),
        Container().setWeight(1),
        ElevatedButton(onPressed: () {
          viewModel.submitSign();
        }, child: CommonText('提交',textColor: Colors.white),style: ButtonStyles.submit_btn_style,)
            .addToContainer(width: double.infinity,margin: EdgeInsets.only(left: 16,right: 16,bottom: 50))
      ],
    );
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      appBar: AppBar(
        title: Text("新增活动信息"),
        centerTitle: true,
      ),
      body: loadingContentWidget,
    );
  }

  @override
  ActivitySignViewModel createViewModel() {
    return ActivitySignViewModel(context,info: widget.info);
  }

  @override
  void onRetryClick() {}
}
